
README file for:

THE VIOLENCE OF LAW-AND-ORDER POLITICS: THE CASE OF LAW ENFORCEMENT CANDIDATES IN BRAZIL

---------------------
Replication notes
----------------------

REPLICATION FILES
- codebook.csv contains information for all datasets and their columns.
- All .r files name exactly what object it produces. Figure 8 requires a google account key to retrieve the Mogi das Cruzes map from google maps.

	Datasets
	- ver_data.csv: this is the main dataset.
	- daily_homicides.rds: This dataset is only used to replicate Figure 6.
	- data_census.rds: This dataset is used for the geospatial SP analysis.
	- clean_plataformas.rds: This dataset replicates tests of mayoral political platforms.
	- map_data_mogi.rds: This dataset is only used to replicate Figure 8.
	- social_media.rds: This dataset replicates social media/credit claiming tests.
	- local.rds: This dataset is used to replicate Table A.4 (local public security institutions)

To replicate the results you will need to run the scripts in R. The replication files run on "R version 4.2.2 (2022-10-31 ucrt)." 

Please note that you will need to install several packages. Importantly, the replication files use the package "here" to organize where the data should be retrieved and where the figure outputs will be stored. I recommend reading the package notes (https://here.r-lib.org/). 

To run the codes, you should first create an "R project" in a folder which will be a top-level directory. In this folder, you will need to create a "data" folder to store all the data files necessary to run the replication. Next, you will need to create "writing" folder, and within that, a "img" folder. You can also keep all the script files at a "code" folder.



root
 |
 --- code
 |
 --- data
 |
 --- writing
	|
	----- img

That should do it. 

The figure files are repetitive. Please refer to "fig_1_panel_b.r" and "fig_1_panels_a_c_table_A13_figure_B3.r" for an annotated version of the main code. 

DATA SOURCES
There are two main data sources, all from Brazilian government: TSE and Datasus/SIM

- TSE: https://dadosabertos.tse.jus.br/. There you will find the candidate's and electoral results information.

- Datasus/SIM: https://datasus.saude.gov.br/transferencia-de-arquivos/ (the original FTP I used to download the data is no longer up). The article uses mortality data starting in 2000 and ending in 2016.

Other data sources include the IBGE, IBGE/MUNIC, IBGE/Census data, and São Paulo Security Cabinet (Secretaria de Segurança de São Paulo).


 


